<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "speak_content".
 *
 * @property integer $id
 * @property integer $hear_number
 * @property integer $question_number
 * @property string $info
 * @property string $content
 * @property integer $class1_id
 * @property integer $class2_id
 * @property integer $num
 * @property string $diff
 * @property string $direction
 * @property string $topic_content
 * @property string $listening_script
 * @property string $listening_content
 * @property string $reading_tips
 * @property string $reading_content
 * @property string $reading_title
 * @property integer $type
 * @property string $img_url
 * @property string $index_img_url
 * @property string $topic_content_english
 *
 * @property Class1 $class1
 * @property Class2 $class2
 * @property SpeakPerson[] $speakPeople
 */
class SpeakingContent extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'speak_content';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['hear_number', 'question_number', 'class1_id', 'class2_id', 'num', 'direction', 'listening_content', 'topic_content_english'], 'required'],
            [['hear_number', 'question_number', 'class1_id', 'class2_id', 'num', 'type'], 'integer'],
            [['info', 'content', 'topic_content', 'listening_script', 'listening_content', 'reading_tips', 'reading_content', 'reading_title', 'topic_content_english'], 'string'],
            [['diff'], 'string', 'max' => 32],
            [['direction', 'img_url', 'index_img_url'], 'string', 'max' => 255],
            [['class1_id'], 'exist', 'skipOnError' => true, 'targetClass' => Class1::className(), 'targetAttribute' => ['class1_id' => 'id']],
            [['class2_id'], 'exist', 'skipOnError' => true, 'targetClass' => Class2::className(), 'targetAttribute' => ['class2_id' => 'id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'hear_number' => 'tpo编号（tpo2里面的2）',
            'question_number' => '听力题号',
            'info' => '简介（显示在首页）',
            'content' => '内容',
            'class1_id' => '一级分类',
            'class2_id' => '二级分类',
            'num' => '做过题目的人数',
            'diff' => '分类',
            'direction' => '音频direction',
            'topic_content' => '题目说明音频',
            'listening_script' => '题目听力音频',
            'listening_content' => '听力原文',
            'reading_tips' => '阅读提示音频',
            'reading_content' => '阅读题目内容',
            'reading_title' => '阅读题目',
            'type' => '题目类型',
            'img_url' => '图片url',
            'index_img_url' => '主页图片url',
            'topic_content_english' => '等待期间显示内容',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getClass1()
    {
        return $this->hasOne(Class1::className(), ['id' => 'class1_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getClass2()
    {
        return $this->hasOne(Class2::className(), ['id' => 'class2_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getSpeakPeople()
    {
        return $this->hasMany(SpeakPerson::className(), ['speak_content_id' => 'id']);
    }
}
